package com.burst.reptile.modular.zp.warpper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.burst.reptile.common.utils.SecurityUtils;
import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.framework.constant.ConstantFactory;
import com.burst.reptile.framework.web.warpper.BaseControllerWrapper;
import com.burst.reptile.modular.system.entity.SysUser;
import com.burst.reptile.modular.zp.entity.ZpFollow;

public class ZpFollowWrapper extends BaseControllerWrapper<ZpFollow> {

    public ZpFollowWrapper(Page<ZpFollow> page) {
        super(page);
    }
    
    public ZpFollowWrapper(List<ZpFollow> list) {
        super(list);
    }
    
    @Override
    protected void wrapTheMap(ZpFollow follow) {
    	Long userId = follow.getUserToFollowId();
    	// 获取粉丝量
    	follow.setFansNum(ConstantFactory.me().getFans(userId));
    	// 获取关注量
    	follow.setFollowNum(ConstantFactory.me().getAttention(userId));
    	// 获取点赞量
    	follow.setGiveNum(ConstantFactory.me().getLikes(userId));
    	// 获取发布量
    	follow.setReleaseNum(ConstantFactory.me().getReleaseVolume(userId));
    	SysUser user = ConstantFactory.me().getUser(userId);
    	if(ToolUtil.isNotEmpty(user)) {
    		// 用户昵称
        	follow.setNickName(user.getNickName());
        	// 用户头像
        	follow.setAvatar(user.getAvatar());
        	// 用户标签
        	follow.setLabel(user.getLabel());
    	}
    	if(SecurityUtils.isLogin()) {
    		Long loginUserId = SecurityUtils.getLoginUserId();
    		// 是否关注
        	if(!userId.equals(loginUserId)) {
        		follow.setFoll(ConstantFactory.me().mutual(userId, loginUserId));
        	}
    	}
    }

}
